﻿using UnityEngine;
using UnityEngine.UI;

namespace Assets.Scripts.UI.Panel
{
    public class CheckScoreTipPanel:UIBase<CheckScoreTipPanel>
    {
        public Toggle AutoBehindToggle;
        public Button ExitButton;
        private string autoBehind = "xxxxx00001";
        protected override UIType UIType
        {
            get { return UIType.Panel;}           
        }

        protected override void InitOnAwake()
        {
            AutoFindComponent(transform,true);
            ExitButton.onClick.AddListener(Exit);
            Init();
        }

        private void Init()
        {
            string value = PlayerPrefs.GetString(autoBehind);
            Debug.Log("value......:"+value);
            if (!string.IsNullOrEmpty(value) && value.Equals("True"))
            {
                Exit();
                return;
            }
            AutoBehindToggle.onValueChanged.AddListener(x =>
            {
                PlayerPrefs.SetString(autoBehind,x.ToString());
            });
        }
    }
}